package com.zy.chapter5

/**
 * @description: ${description}
 * @author: zhaoyi
 * @create: 2020-04-23 22:46
 **/
class Person {

  private var privateAge: Int = 1

  //相当于java的getXX方法
  def age = privateAge

  //相当于java的setXX方法，字节码也是age_$eq
  //这里age_=连一块的
  def age_=(newAge: Int) {
    //不能变年轻
    if (newAge > privateAge) {
      privateAge = newAge
    }
  }


}
